from rest_framework import serializers

from goods.models import SpecificationOption, SPUSpecification


class OptionSerializer(serializers.ModelSerializer):
    """规格选项序列化器类"""
    spec_id = serializers.IntegerField(label='规格选项id')

    spec = serializers.StringRelatedField(label='规格名称')

    class Meta:
        model = SpecificationOption
        fields = ('id', 'spec', "value", 'spec_id')


class OptionSimpleSerializer(serializers.ModelSerializer):
    """规格选项简单展示序列化器类"""
    # spec_id = serializers.IntegerField(label='规格ID')
    class Meta:
        model = SPUSpecification
        fields = ('id','name')
